package ui.panels.primary.adaptiveAgentProperties;

import gameEngine.agents.choosingStrategy.representation.EGreedyRepresentation;
import gameEngine.agents.choosingStrategy.representation.GreedyRepresentation;
import gameEngine.agents.choosingStrategy.representation.ManuallAdaptiveRepresentation;
import gameEngine.agents.choosingStrategy.representation.RoundRobinRepresentation;
import gameEngine.agents.choosingStrategy.representation.SelectWorstRepresentation;
import gameEngine.agents.choosingStrategy.representation.SimpleRandomRepresentation;
import gameEngine.agents.choosingStrategy.representation.StrategyRepresentation;
import gameEngine.agents.distrebution.representation.DistributionRepresentation;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.swing.DefaultCellEditor;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;

import org.apache.log4j.Logger;

import ui.flowManager.FlowManagerImpl;
import ui.flowManager.expirimentProperties.AdditionalSettings;
import ui.flowManager.expirimentProperties.AgentRepresentation;
import ui.flowManager.expirimentProperties.ExperimentProperties;
import ui.flowManager.expirimentProperties.ExperimentProperties.Agent_Group;
import ui.panels.additionalSettings.AdditionalSettingsFrame;
import ui.panels.additionalSettings.AdditionalSettingsPanel;
import ui.panels.commands.DistributionFrameCommand;

import Data.ConfigurationParameters;

import auxiliary.AuxiliaryClass;

import com.cloudgarden.layout.*;



/**
 * @author vladimir && alon
 *
 * GUI of the player's properties
 */
public  class AdaptiveAgentProperties extends JPanel{
	private static 		ArrayList<String> distributionList = null;
	private static 		ArrayList<String> strategyList = null;
	private static 		ArrayList<String> teammateModelList = null;
	private static 		ArrayList<String> analyzerlList = null;
	
	List<TableCellEditor> 		editors = new ArrayList<TableCellEditor>();
    private int 				numRows = 0;
    private JTable 				table = null;
   // private JScrollPane 		scrollPane = null;
    private DefaultTableModel 	model = null;
    private JButton 			save;

    private JLabel 				competenceLabel = null;
    private JLabel 				EpsilonLabel;
    private JLabel 				analyzeLabel;
    private JLabel 				DistributionLabel;
    private JLabel 				teammateLabel;
    private JLabel 				AgentNumber;
    
    private JTextField 			epsilonField;
    private JTextField 			competenceField;
    private JTextField 			gameRepeatsField;
    
    private JComboBox 			distributionDrop;
    private JComboBox 			teammatedrop;
    private JComboBox 			analyzerDrop;
    
    private JScrollPane 		scrollPane;
    private  JComboBox 			strategyComboBox = null; 
    private DefaultCellEditor 	defaultCellEditor=null;
    
    private JButton 			addStrategy = null;
    private JButton 			additionalSettingsButton = null;
    
    //private  StrategyFrame	 	myFrame = null;		
	private int 				gameNumber = 0;
	private int 				playerNumber = 0;
	private int					turnsInGame = 0;

	private DistributionRepresentation 	distRepresentation = null;
	private AdditionalSettings 			additionalSettings = null;
	private final Agent_Group 			group = Agent_Group.STUDIED_AGENT;
	Logger log = Logger.getLogger(this.getClass());
	
	/*** Set a special look for the window*/
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Default CTOR
	 */
	public	AdaptiveAgentProperties(){}
	
	/** 
	 * @param playerNumber
	 */
	public	AdaptiveAgentProperties(int gamenumber , int	playerNumber)
	{
		this.gameNumber		=	gamenumber;
		this.playerNumber 	=	playerNumber;
	}
	

	public void show(ExperimentProperties props) {
		// TODO Auto-generated method stub
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)this);
			this.setLayout(thisLayout);
			setPreferredSize(new Dimension(339, 480));

			//turns in game
			turnsInGame = props.getNumOfTurns(gameNumber);
	        //  Create the table with default data
	        Object[][] data =
	        {
	           // {ConfigurationParameters.Strategy.EGREEDY, "0"}
	        };
	        String[] columnNames = {"Strategy","Turns"};
	        		
	        model = new DefaultTableModel(data, columnNames);
	        table = new JTable(model)
	        {
	            //  Determine editor to be used by row
	            public TableCellEditor getCellEditor(int row, int column)
	            {
	                int modelColumn = convertColumnIndexToModel( column );

	                if (modelColumn == 0 && row < numRows)
                		return editors.get(row);
	                else
	                    return super.getCellEditor(row, column);
	            }     
	        };
	        table.getColumnModel().getColumn(0).setPreferredWidth(100);
	        table.getColumnModel().getColumn(1).setPreferredWidth(25);
	     
	        scrollPane = new JScrollPane( table );
		
	        AgentNumber = new JLabel("",JLabel.CENTER);
	        AgentNumber.setFont(new Font(Font.SERIF, Font.ROMAN_BASELINE, 20));
	        
	        {
	        	analyzeLabel = new JLabel("Analyzer", JLabel.CENTER);
	        }
	        {
	        	analyzerDrop = new JComboBox();
	        }
	        {
	        	save = new JButton();
	        	save.setText("Save Player");
	        }
	        {
	        	additionalSettingsButton = new JButton();
	        	additionalSettingsButton.setText("Additional Settings");
	        }
	        {
	        	epsilonField = new JTextField();
	        }
	        {
	        	competenceField = new JTextField();
	        }
	        {
	        	gameRepeatsField = new JTextField();
	        }
	        {
	        	EpsilonLabel = new JLabel("Epsilon",JLabel.CENTER);
	        }
	        {
	        	competenceLabel = new JLabel("Competence",JLabel.CENTER);
	        }
	        {
	        	DistributionLabel = new JLabel("Distribution", JLabel.CENTER);
	        }
	        {
	        	distributionDrop = new JComboBox();
	        }
	        {
	        	teammatedrop = new JComboBox();
	        }
	        {
	        	teammateLabel = new JLabel();
	        	teammateLabel.setText("TeammateModel");
	        }

			addStrategy = new JButton();
			addStrategy.setText("+");

			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
					.addContainerGap(14, 14)
					.addComponent(AgentNumber, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
					.addGroup(thisLayout.createParallelGroup()
					    .addComponent(scrollPane, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE)
					    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					        .addGap(52)
					        .addComponent(addStrategy, GroupLayout.PREFERRED_SIZE, 68, GroupLayout.PREFERRED_SIZE)
					        .addGap(45)))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(teammateLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
					    .addComponent(DistributionLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
					.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(teammatedrop, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(distributionDrop, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(analyzeLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
					.addComponent(analyzerDrop, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(competenceLabel, GroupLayout.Alignment.BASELINE, 0, 23, Short.MAX_VALUE)
					    .addComponent(EpsilonLabel, GroupLayout.Alignment.BASELINE, 0, 23, Short.MAX_VALUE))
					.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(epsilonField, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(competenceField, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(additionalSettingsButton, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(save, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(34, 34));
				thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
					.addContainerGap(12, 12)
					.addGroup(thisLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					        .addComponent(distributionDrop, GroupLayout.PREFERRED_SIZE, 138, GroupLayout.PREFERRED_SIZE)
					        .addGap(21)
					        .addGroup(thisLayout.createParallelGroup()
					            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                .addComponent(competenceLabel, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
					                .addGap(0, 34, Short.MAX_VALUE))
					            .addGroup(thisLayout.createSequentialGroup()
					                .addPreferredGap(competenceLabel, teammatedrop, LayoutStyle.ComponentPlacement.INDENT)
					                .addGroup(thisLayout.createParallelGroup()
					                    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                        .addComponent(teammatedrop, GroupLayout.PREFERRED_SIZE, 138, GroupLayout.PREFERRED_SIZE)
					                        .addGap(0, 10, Short.MAX_VALUE))
					                    .addGroup(thisLayout.createSequentialGroup()
					                        .addPreferredGap(teammatedrop, teammateLabel, LayoutStyle.ComponentPlacement.INDENT)
					                        .addGroup(thisLayout.createParallelGroup()
					                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                                .addComponent(teammateLabel, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
					                                .addGap(0, 38, Short.MAX_VALUE))
					                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                                .addGap(0, 18, Short.MAX_VALUE)
					                                .addComponent(competenceField, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)
					                                .addComponent(addStrategy, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE))))))))
					    .addGroup(thisLayout.createSequentialGroup()
					        .addGap(12)
					        .addGroup(thisLayout.createParallelGroup()
					            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 234, GroupLayout.PREFERRED_SIZE)
					                .addGap(0, 49, Short.MAX_VALUE))
					            .addGroup(thisLayout.createSequentialGroup()
					                .addPreferredGap(scrollPane, EpsilonLabel, LayoutStyle.ComponentPlacement.INDENT)
					                .addGroup(thisLayout.createParallelGroup()
					                    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                        .addGroup(thisLayout.createParallelGroup()
					                            .addComponent(EpsilonLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
					                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                                .addComponent(DistributionLabel, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
					                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)))
					                        .addGap(10)
					                        .addComponent(analyzeLabel, GroupLayout.PREFERRED_SIZE, 92, GroupLayout.PREFERRED_SIZE)
					                        .addGap(0, 85, Short.MAX_VALUE))
					                    .addGroup(thisLayout.createSequentialGroup()
					                        .addPreferredGap(EpsilonLabel, additionalSettingsButton, LayoutStyle.ComponentPlacement.INDENT)
					                        .addGroup(thisLayout.createParallelGroup()
					                            .addComponent(additionalSettingsButton, GroupLayout.Alignment.LEADING, 0, 271, Short.MAX_VALUE)
					                            .addComponent(save, GroupLayout.Alignment.LEADING, 0, 271, Short.MAX_VALUE)
					                            .addGroup(thisLayout.createSequentialGroup()
					                                .addPreferredGap(additionalSettingsButton, epsilonField, LayoutStyle.ComponentPlacement.INDENT)
					                                .addGroup(thisLayout.createParallelGroup()
					                                    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                                        .addComponent(epsilonField, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)
					                                        .addGap(0, 120, Short.MAX_VALUE))
					                                    .addGroup(thisLayout.createSequentialGroup()
					                                        .addGap(39)
					                                        .addGroup(thisLayout.createParallelGroup()
					                                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                                                .addComponent(AgentNumber, GroupLayout.PREFERRED_SIZE, 141, GroupLayout.PREFERRED_SIZE)
					                                                .addGap(0, 9, Short.MAX_VALUE))
					                                            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
					                                                .addGap(12)
					                                                .addComponent(analyzerDrop, GroupLayout.PREFERRED_SIZE, 138, GroupLayout.PREFERRED_SIZE)
					                                                .addGap(0, 0, Short.MAX_VALUE)))))
					                                .addGap(76)))))))
					        .addGap(18)))
					.addContainerGap(14, 14));		
			
		} catch (Exception e) {
			log.debug(e.toString());
		}
		
		//add listeners to components
		setListeners(props);
		
		//set the component options
		SetComponentsOptions();
		
		//case the properties are real one - attached to some player
		if(isAttachedToPlayer())
		{
			//set the label
			setPlayerLabel(props);
			//set all the rest 
			setPlayerPropFromExpirimentProperties(props);	
		}
		createAdditionalSettings();
	}
	//------------	end show	-----------------------
	
	
	/*** @param playerNumber */
	public void setPlayerLabel(ExperimentProperties props)
	{
		AgentNumber.setText("Studied Player " + playerNumber);
		
		//case not initialized the label will be in red
		if(!props.isPlayerInitialized(gameNumber, playerNumber, group))
		{
			labelToRed();
		}
	}

	
	/*** The label letters became in color red	 */
	private void labelToRed()
	{
		AgentNumber.setForeground(Color.RED);
	}
	
	/*** The label letters became in color black	*/
	public void labelToBlack()
	{
		AgentNumber.setForeground(Color.BLACK);
	}
	
	/**
	 * Set the listeners of the components
	 */
	//private void setListeners(final ExperimentProperties props)
	private void setListeners(final ExperimentProperties props)
	{
		AdaptivePropertiesListener adaptivePropertiesListener = new AdaptivePropertiesListener(this, props);	
		save.addActionListener(adaptivePropertiesListener);
		addStrategy.addActionListener(adaptivePropertiesListener);
		additionalSettingsButton.addActionListener(adaptivePropertiesListener);
		
		distributionDrop.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent event) {
				//case it attached and distribution combo
				if((isAttachedToPlayer())&&(event.getSource() == distributionDrop))
				{
					//get the distribution from the combo box
					String distribution = (String) distributionDrop.getSelectedItem();
					//create the command for the distribution frame
					DistributionFrameCommand command = new DistributionFrameCommand();
					command.setDistribution(distribution);
					command.setGroup(group);
					command.setGameNumber(gameNumber);
					command.setPlayerNumber(playerNumber);
					command.execute();
				}			
			}
			
		});
	}
	//end of function setListeners
	
		
	private void createAdditionalSettings()
	{
		if (additionalSettings == null)
			additionalSettings =  new AdditionalSettings();
	}
	
	public void additionalSettingsButtonFunc(ExperimentProperties props)
	{
		AdditionalSettingsFrame frame = new AdditionalSettingsFrame();
		AdditionalSettingsPanel panel = new AdditionalSettingsPanel(frame, this, additionalSettings);
		frame.add(panel);
	}
	
	
	/**
	 * Add Row to the table 
	 */
	public void addRow(String strategyName)
	{
		//find the number of turns that remain in the game
        int turns = turnsRemain();
        String turnsStr = Integer.toString(turns);
        addInitializedRow(strategyName, turnsStr);
	}
	
	/**
	 * 
	 */
	private void SetComponentsOptions()
	{
		//case there is distributionList
		if(distributionList != null)
		{
			for(int i = 0; i < distributionList.size(); ++i){
				distributionDrop.addItem(distributionList.get(i));
			}	
		}
		
		//case there is teammateModelList
		if(teammateModelList != null)
		{	//add team mate models to comboBox
			for(int i = 0; i < teammateModelList.size(); ++i){
				teammatedrop.addItem(teammateModelList.get(i));
			}
		}
		
		//case there is analyzerlList
		if(analyzerlList != null)
		{	//add analyzers to comboBox
			for(int i = 0; i < analyzerlList.size(); ++i){
				analyzerDrop.addItem(analyzerlList.get(i));
			}
		}	
		//for the strategies
		initializeComboBox();
	}

	/**
	 * @return true/false
	 */
	private boolean isAttachedToPlayer()
	{
		return (playerNumber > 0);
	}
	
	private void setPlayerPropFromExpirimentProperties(ExperimentProperties props)
	{
		//case the player is initialized
		if(props.isPlayerInitialized(gameNumber, playerNumber, group))
		{
			//set the player
			setPlayerProperties(props);
		}
	}
	
	
	/*** @param props */
	private void setPlayerProperties(ExperimentProperties props)
	{
		AgentRepresentation agentRepresentation = props.getPlayer(gameNumber, playerNumber, group);	
		//set the additional settings
		this.additionalSettings = agentRepresentation.getAdditionalSettings();	
		//set the drops from player properties
		teammatedrop.setSelectedItem(agentRepresentation.getTeammateModelType());
		analyzerDrop.setSelectedItem(agentRepresentation.getAnalyzerType());
		distributionDrop.setSelectedItem(agentRepresentation.getDistributionType().getDistributionName());	
		//set the text field
		epsilonField.setText(Double.toString(agentRepresentation.getEpsilon()));
		competenceField.setText(Double.toString(agentRepresentation.getCompetence()));	
		//set the strategies in the table
		setStrategies();
	}
	
	/**
	 * Set the previous saved strategies of the player in the table
	 */
	private void setStrategies()
	{
		//first check if previous strategy was also manual
		
		AgentRepresentation agRepresentation = FlowManagerImpl.
				getInstance().getProps().getPlayer(gameNumber, playerNumber, group);	
		StrategyRepresentation strRepresentation = agRepresentation.getStrategyType();	
		//case not manual
		if(! (strRepresentation instanceof ManuallAdaptiveRepresentation))
			return;
		
		//cast to manual
		ManuallAdaptiveRepresentation manualRepresentation = (ManuallAdaptiveRepresentation) strRepresentation;
		int numStrategies = manualRepresentation.numberOfStrategies();
		//take the strategies and put them to table
		for (int i = 0; i < numStrategies; ++i)
		{
			StrategyRepresentation strategy = manualRepresentation.getStrategy(i + 1);
			int turns = manualRepresentation.getNumberTurns(i + 1);
			String turnsStr = Integer.toString(turns);
			//add to table
			addInitializedRow(strategy.getStrategyName(), turnsStr);
		}	
	}
	


	/**
	 * Create && return representation for strategy
	 * @param name
	 * @return strategyRepresentation
	 */
	public StrategyRepresentation createStrategyRepresentation(String name)
	{
		StrategyRepresentation strategyRepresentation = null;
		
		if(name.equals(ConfigurationParameters.Strategy.EGREEDY))
		{
			strategyRepresentation= new 
						EGreedyRepresentation(ConfigurationParameters.Strategy.EGREEDY);
		}	
		else if(name.equals(ConfigurationParameters.Strategy.GREEDY))
		{
			strategyRepresentation = new
				GreedyRepresentation(ConfigurationParameters.Strategy.GREEDY);
		}
		else if(name.equals(ConfigurationParameters.Strategy.ROUND_ROBIN))
		{
			strategyRepresentation = new
				RoundRobinRepresentation(ConfigurationParameters.Strategy.ROUND_ROBIN);
		}
		else if(name.equals(ConfigurationParameters.Strategy.SELECT_WORST))
		{
			strategyRepresentation = new 
				SelectWorstRepresentation(ConfigurationParameters.Strategy.SELECT_WORST);
		}
		else if(name.equals(ConfigurationParameters.Strategy.SIMPLE_RANDOM))
		{
			strategyRepresentation = new 
				SimpleRandomRepresentation(ConfigurationParameters.Strategy.SIMPLE_RANDOM);
		}
		
		return strategyRepresentation;
	}
	
	
	
	/**
	 * Calculate number of turns that can be use in next strategy
	 * @return turns that remain 
	 */
	private int turnsRemain()
	{
		int totalTurns  = 0;
		//go over the table and count the turns that was sset
		for(int i = 0; i < numRows; ++i)
		{
			//number of turns
			String turnsStr = (String) model.getValueAt(i, 1);
			 if(AuxiliaryClass.isNumber(turnsStr))
			 {
				 totalTurns = totalTurns + Integer.parseInt(turnsStr);
			 }
		}
		
		return turnsInGame - totalTurns;
	}
	
	/**
	 * Initialize the strategies that in the table drop box
	 */
	private void initializeComboBox()
	{	
		String[] strategies = new String[strategyList.size() - 1]; 
		for (int i = 0, j = 0; i < strategyList.size(); ++i)
		{
			if (!strategyList.get(i).equals(ConfigurationParameters.Strategy.MANUAL_ADAPTIVE))
			{
				strategies[j] = strategyList.get(i);
				++j;
			}
		}
		
	    strategyComboBox = new JComboBox( strategies );
        defaultCellEditor = new DefaultCellEditor(strategyComboBox);
        editors.add(defaultCellEditor);	       
        numRows = 0;
	}
	

	private void addInitializedRow(String strategyName, String turns)
	{
		Vector<String> vec = new Vector<String>();
	    vec.add(strategyName);
        vec.add(turns);
        model.addRow(vec);
        //have to add cell !!!
        editors.add(defaultCellEditor);
        ++numRows;
	}
	
	
	/** @param distRepresentation */
	public void setDistRepresentation(DistributionRepresentation distRepresentation) {
		this.distRepresentation = distRepresentation;
	}
	
	public void setAdditionalSettings(AdditionalSettings additionalSettings) {
		this.additionalSettings = additionalSettings;
	}
	
	public AdditionalSettings getAdditionalSettings() {
		return additionalSettings;
	}

	public JButton getAddStrategy() {
		return addStrategy;
	}

	public JButton getSave() {
		return save;
	}

	public int getNumRows() {
		return numRows;
	}

	public DefaultTableModel getModel() {
		return model;
	}

	public JTextField getEpsilonField() {
		return epsilonField;
	}

	public JTextField getCompetenceField() {
		return competenceField;
	}

	public JTextField getGameRepeatsField() {
		return gameRepeatsField;
	}
	
	public DistributionRepresentation getDistRepresentation() {
		return distRepresentation;
	}

	public JComboBox getTeammatedrop() {
		return teammatedrop;
	}

	public JComboBox getAnalyzerDrop() {
		return analyzerDrop;
	}

	public JComboBox getStrategyComboBox() {
		return strategyComboBox;
	}

	public int getGameNumber() {
		return gameNumber;
	}

	public int getPlayerNumber() {
		return playerNumber;
	}

	public static void setDistributionList(ArrayList<String> distributionList) {
		AdaptiveAgentProperties.distributionList = distributionList;
	}

	public static void setStrategyList(ArrayList<String> strategyList) {
		AdaptiveAgentProperties.strategyList = strategyList;
	}

	public static void setTeammateModelList(ArrayList<String> teammateModelList) {
		AdaptiveAgentProperties.teammateModelList = teammateModelList;
	}

	public static void setAnalyzerlList(ArrayList<String> analyzerlList) {
		AdaptiveAgentProperties.analyzerlList = analyzerlList;
	}

	public JButton getAdditionalSettingsButton() {
		return additionalSettingsButton;
	}
}
